#include <asm/atomic.h>
#include <asm/irqflags.h>

int arch_atomic_add_return(int i, atomic_t *v)
{
    unsigned long flags;
    int val;

    flags = arch_local_irq_save();
    v->counter += i;
    val = v->counter;
    arch_local_irq_restore(flags);

    return val;
}

int arch_atomic_fetch_add(int i, atomic_t *v)
{
    unsigned long flags;
    int val;

    flags = arch_local_irq_save();
    val = v->counter;
    v->counter += i;
    arch_local_irq_restore(flags);

    return val;
}

void arch_atomic_add(int i, atomic_t *v)
{
    v->counter += i; //TODO
}

void arch_atomic_sub(int i, atomic_t *v)
{
    v->counter -= i; //TODO
}
